#include <func.h>

void test1(void)
{
    printf("test1 !\n");
}

void test2(void)
{
    printf("test 2!\n");
}

void printfExit(int exitstatus,void* arg)
{
    printf("on_exit:status = %d,arg = %s\n",exitstatus,(char*)arg);
}

int main(void)
{
    int pid = fork();


    switch (pid)
    {
        case -1:
            error(1,errno,"fork");
        case 0:
            atexit(test1);
            atexit(test2);
            
            printf("child:pid = %d,parent:pid = %d\n",getpid(),getppid());
            on_exit(printfExit,(void*) "10086");

            exit(1);
            break;
        default:
            test2();
            printf("parent:pid = %d,child:pid = %d\n",getpid(),pid);
            printf("test buff flash!");

            exit(2);
            break;
    }
    return 0;
}
